package com.bawei.mvvmzonghe.viewmodel;

import com.bawei.mvvmzonghe.entity.BaseResponseEntity;
import com.bawei.mvvmzonghe.entity.GoodsEntity;
import com.bawei.mvvmzonghe.entity.CateGoryEntity;
import com.bawei.mvvmzonghe.respository.GoodsRepository;

import java.util.List;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.ViewModel;

/**
 * @Author : yaotianxue
 * @Time : On 2023/9/14 10:00
 * @Description : GoodsViewModel
 */
public class GoodsViewModel extends ViewModel {
    private GoodsRepository mGoodsRepository = new GoodsRepository();
    //分类
    public LiveData<BaseResponseEntity<List<CateGoryEntity>>> type(int type){
        return mGoodsRepository.type(type);
    }

    //商品
    public LiveData<BaseResponseEntity<GoodsEntity>> goods(int id, int page, int size){
        return mGoodsRepository.goods(id,page,size);
    }


    //room：存储数据
    public void insert(List<GoodsEntity.ListBean> list){
        mGoodsRepository.insert(list);
    }
    //room 数据库查询数据
    public LiveData<List<GoodsEntity.ListBean>> getRoomGoods(){
        return mGoodsRepository.getRoomGoods();
    }
}
